home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- branch ;
- access ;
- symbols ;
- locks shirriff:1.3; strict;
- comment @ * @;
-
-
- 1.3
- date 90.04.12.17.40.43; author douglis; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 89.07.26.23.49.05; author rab; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 89.07.26.23.46.35; author rab; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.3
- log
- @ifdef'ed out open of /dev/tty for sprite.
- @
- text
- @/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
- #ifndef lint
- static char sccsid[] = "@@(#)getpass.c 5.5 (Berkeley) 3/14/88";
- #endif /* not lint */
-
- #include <stdio.h>
- #include <signal.h>
- #include <sgtty.h>
-
- #include "ftp_var.h"
-
- static struct sgttyb ttyb;
- static int flags;
- static FILE *fi;
-
- static intfix()
- {
- ttyb.sg_flags = flags;
- if (fi != NULL)
- (void) stty(fileno(fi), &ttyb);
- exit(SIGINT);
- }
-
- char *
- mygetpass(prompt)
- char *prompt;
- {
- register char *p;
- register c;
- static char pbuf[50+1];
- int (*sig)();
-
- #ifndef sprite
- if ((fi = fopen("/dev/tty", "r")) == NULL)
- fi = stdin;
- else
- setbuf(fi, (char *)NULL);
- #else /* sprite */
- fi = stdin;
- #endif /* sprite */
-
- sig = signal(SIGINT, intfix);
- (void) gtty(fileno(fi), &ttyb);
- flags = ttyb.sg_flags;
- ttyb.sg_flags &= ~ECHO;
- (void) stty(fileno(fi), &ttyb);
- fprintf(stderr, "%s", prompt); (void) fflush(stderr);
- for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
- if (p < &pbuf[sizeof(pbuf)-1])
- *p++ = c;
- }
- *p = '\0';
- fprintf(stderr, "\n"); (void) fflush(stderr);
- ttyb.sg_flags = flags;
- (void) stty(fileno(fi), &ttyb);
- (void) signal(SIGINT, sig);
- if (fi != stdin)
- (void) fclose(fi);
- return(pbuf);
- }
- @
-
-
- 1.2
- log
- @
- @
- text
- @d44 1
- d49 4
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d21 2
- a41 1
- int (*signal())();
- @
-